package cn.eyesea.cc.frame.enums;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 逻辑层类型枚举
 *
 * @author wanghuilong
 * @version 1.0
 * @date 2021/6/11 3:58 下午
 */
public enum LogicalLayerTypeEnum {

    DAO("持久化层", 0, "dao", Arrays.asList(), Arrays.asList(LogicalTypeEnum.DAO, LogicalTypeEnum.MAPPER, LogicalTypeEnum.ENTITY)),
//    MANAGER("通用能力层",1,"manager", Arrays.asList(DAO), Arrays.asList()),
//    SERVICE("业务能力层",2,"service", Arrays.asList(MANAGER), Arrays.asList())
    ;


    private String desc;

    /**
     * 顺序
     */
    private Integer index;

    /**
     * 包名
     */
    private String packageInfo;

    /**
     * 依赖层集合
     */
    private List<LogicalLayerTypeEnum> relyLayers;

    /**
     * 逻辑类型集合
     */
    private List<LogicalTypeEnum> logicalTypeList;


    LogicalLayerTypeEnum(String desc, Integer index, String packageInfo, List<LogicalLayerTypeEnum> relyLayers
            , List<LogicalTypeEnum> logicalTypeList) {
        this.desc = desc;
        this.index = index;
        this.packageInfo = packageInfo;
        this.relyLayers = relyLayers;
        this.logicalTypeList = logicalTypeList;
    }

    public String getDesc() {
        return desc;
    }

    public Integer getIndex() {
        return index;
    }

    public String getPackageInfo() {
        return packageInfo;
    }

    public List<LogicalTypeEnum> getLogicalTypeList() {
        return logicalTypeList;
    }

    public List<LogicalLayerTypeEnum> getRelyLayers() {
        return relyLayers;
    }

    public static List<LogicalLayerTypeEnum> getLogicalLayerTypeByIndex() {
        return Stream.of(LogicalLayerTypeEnum.values()).sorted((o1, o2) -> o1.index.compareTo(o2.index))
                .collect(Collectors.toList());
    }

}
